package com.logistics.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.logistics.TimeTemplate;
import com.logistics.admin.AdminGenericBaseAction;
import com.logistics.service.TimeTemplateService;

@Component("timeTemplateAdminAction")
@Scope("prototype")
public class TimeTemplateAdminAction extends AdminGenericBaseAction<TimeTemplate, TimeTemplateService> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private TimeTemplateService service;
	
	@Autowired
	public void setService(TimeTemplateService service) {
		this.service = service;
	}

	@Override
	public TimeTemplateService getService() {
		return service;
	}
	
	private List<TimeTemplate> templates;

	public List<TimeTemplate> getTemplates() {
		return templates;
	}

	public void setTemplates(List<TimeTemplate> templates) {
		this.templates = templates;
	}
	
	private TimeTemplate template;

	public TimeTemplate getTemplate() {
		return template;
	}

	public void setTemplate(TimeTemplate template) {
		this.template = template;
	}

	@Override
	protected TimeTemplate initEntityForAdd() {
		return template;
	}
	
	public String list() {
		templates = service.query();
		
		return LIST;
	}
	
	@Override
	protected void initEditForm() {
		template = service.getById(getId());
		super.initEditForm();
	}

}
